package so.sao.shop.supplier.dao;

import org.apache.ibatis.annotations.Param;
import so.sao.shop.supplier.domain.ServiceLogistics;
import so.sao.shop.supplier.pojo.input.ExchangePurchaseItemInput;
import so.sao.shop.supplier.pojo.input.ReturnPurchaseSelectInput;
import so.sao.shop.supplier.pojo.output.ExchangePurchaseItemOutput;
import so.sao.shop.supplier.pojo.output.ReturnAndExchangeDetailOutput;
import so.sao.shop.supplier.pojo.vo.ReturnPurchasesVo;

import java.util.Date;
import java.util.List;

/**
 * <p>Version: New shop-1.2.0 V1.1.0 </p>
 * <p>Title: ReturnAndExchangeDao</p>
 * <p>Description: 退换货DAO</p>
 *
 * @author: zhaoyan
 * @Date: Created in 2017/11/29 9:53
 */
public interface ReturnAndExchangeDao {
    /**
     * 查询订单换货列表，供应商与管理员通用
     * @param exchangePurchaseItemInput 换货列表入参对象
     * @return 换货列表出参对象集合
     */
    List<ExchangePurchaseItemOutput> findExchange(ExchangePurchaseItemInput exchangePurchaseItemInput);

    /**
     * 根据详情编号查询退换货详情信息
     * @param detailsId 详情编号ID
     * @return 退换货详情出参对象
     */
    ReturnAndExchangeDetailOutput findDetail(Long detailsId);

    /**
     * 退货列表
     * @param returnPurchaseSelectInput
     * @return List<ReturnPurchasesVo>
     */
    List<ReturnPurchasesVo> findPage(@Param("returnPurchaseSelectInput") ReturnPurchaseSelectInput returnPurchaseSelectInput);

    /**
     * 根据详情编号ID查询该子订单状态
     * @param detailsId
     * @return
     */
    int findStatusByDetailsId(Long detailsId);

    /**
     * 子订单退换货审核
     * @param detailsId 详情编号ID
     * @param status 审核结果，2.审核通过,3.拒绝退款/换货
     * @param refuseReason 拒绝原因
     * @param checkTime 审核时间
     */
    void auditPurchaseItem(@Param("detailsId") Long detailsId, @Param("status")int status,
                           @Param("refuseReason")String refuseReason ,@Param("checkTime")Date checkTime);

    /**
     * 添加订单退换货物流信息
     * @param serviceLogistics 退换货物流domain
     */
    void deliverGoods(ServiceLogistics serviceLogistics);

    /**
     * detailsId下供应商换货物流信息存在性校验
     * @param detailsId 详情编号ID
     * @return
     */
    int countReturnDeliverGoods(@Param("detailsId")Long detailsId);

    /**
     * 更新换货订单发货时间与订单状态
     * @param detailsId 详情编号ID
     * @param sendTime 换货时间
     */
    void updateSendTimeAndStatus(@Param("detailsId")Long detailsId, @Param("sendTime")Date sendTime);

    /**
     * 根据detailsId查询OrderId
     * @param detailsId 详情编号ID
     * @return
     */
    String findOrderIdByDetailsId (@Param("detailsId")Long detailsId);

    /**
     * 根据orderId查询所有子订单状态
     * @param orderId 订单ID
     * @return
     */
    List<Integer> findAllStatusByDetailsId(@Param("orderId")String orderId);

    /**
     * 根据orderId查询主订单确认收货时间
     * @param orderId 订单ID
     * @return
     */
    Date findOrderReceiveTime(@Param("orderId")String orderId);
}

